var findNthDigit = function(n) {
    let l = 10
    let i = 1
    let lastI = 0
    let m
    if(n<10){
        return n
    }
    while(n >= l){
        lastI = l
        l += (i+1)*9*Math.pow(10,i)
        i++
    }
    n = n-lastI
    m = Math.pow(10,i-1)
    let a = n/(i)
    let b = n%(i)
    let c = (a+m).toString()
    return c.substring(b,(b+1))
};
// console.log(findNthDigit(10000000)) 
let n = 11
let l = 10
let i = 1
let lastI = 0
let m
if(n<10){
    return n
}
while(n >= l){
    lastI = l
    l += (i+1)*9*Math.pow(10,i)
    i++
}
n = n-lastI
m = Math.pow(10,i-1)
let a = n/(i)
let b = n%(i)
let c = (a+m).toString()
console.log(lastI,24,l,n,m,a,b,(a+m),c,i)
console.log((a+m).toString().substring(b,(b+1)))